package com.dys.flink.wc.netty.handler;

import com.dys.flink.wc.model.Product;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ProductClientHandler extends SimpleChannelInboundHandler<Product> {
    private static final Logger logger = LoggerFactory.getLogger(ProductClientHandler.class);
    
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Product product) throws Exception {
        logger.info("Received product from server: {}", product);
    }
    
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        logger.error("Client error", cause);
        ctx.close();
    }
}